package com.ramotion.expandingcollection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * CardDataImpl
 *
 * @since 2021-05-31
 */
public class CardDataImpl implements EcCardData<CardList> {
    private String cardTitle;
    private Integer mainBackgroundResource;
    private Integer headBackgroundResource;
    private List<CardList> listItems;

    /**
     * CardDataImpl
     *
     * @param cardTitle
     * @param mainBackgroundResource
     * @param headBackgroundResource
     * @param listItems
     */
    public CardDataImpl(String cardTitle, Integer mainBackgroundResource, Integer headBackgroundResource,
                        List<CardList> listItems) {
        this.mainBackgroundResource = mainBackgroundResource;
        this.headBackgroundResource = headBackgroundResource;
        this.listItems = listItems;
        this.cardTitle = cardTitle;
    }

    /**
     * getMainBackgroundResource
     *
     * @return mainBackgroundResource
     */
    @Override
    public Integer getMainBackgroundResource() {
        return mainBackgroundResource;
    }

    /**
     * getHeadBackgroundResource
     *
     * @return headBackgroundResource
     */
    @Override
    public Integer getHeadBackgroundResource() {
        return headBackgroundResource;
    }

    /**
     * getListItems
     *
     * @return listItems
     */
    @Override
    public List<CardList> getListItems() {
        return listItems;
    }

    /**
     * getCardTitle
     *
     * @return cardTitle
     */
    public String getCardTitle() {
        return cardTitle;
    }

    /**
     * generateExampleData
     *
     * @return dd
     */
    public static List<EcCardData> generateExampleData() {
        List<EcCardData> list = new ArrayList<>();
        list.add(new CardDataImpl("Card 1", ResourceTable.Media_attractions, ResourceTable.Media_attractions_head,
                createItemsList("Card 1")));
        list.add(new CardDataImpl("Card 2", ResourceTable.Media_city_scape, ResourceTable.Media_city_scape_head,
                createItemsList("Card 2")));
        list.add(new CardDataImpl("Card 3", ResourceTable.Media_nature, ResourceTable.Media_nature_head,
                createItemsList("Card 3")));
        return list;
    }

    private static List<CardList> createItemsList(String cardName) {
        ArrayList<CardList> list = new ArrayList<>();
        list.addAll(Arrays.asList(
                new CardList(cardName + " - Item 1", false),
                new CardList(cardName + " - Item 2", false),
                new CardList(cardName + " - Item 3", false),
                new CardList(cardName + " - Item 4", false),
                new CardList(cardName + " - Item 5", false),
                new CardList(cardName + " - Item 6", false),
                new CardList(cardName + " - Item 7", false),
                new CardList(cardName + " - Item 7", false)

        ));
        return list;
    }
}